﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using Dictionary.ERP;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;

    public class xfmInsertSymbol : XtraForm
    {
        private SimpleButton btCancel;
        private SimpleButton btCreate;
        private CalcEdit calFromRow;
        private CalcEdit calToRow;
        private CheckEdit cheAll;
        private GridColumn colSymbolCode;
        private GridColumn colSymbolName;
        private IContainer components;
        private GridLookUpEdit glkSymbol;
        private GridView gridLookUpEdit1View;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private DevExpress.Utils.ImageCollection imageCollection1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LabelControl lcDescription;
        private int m_Month;
        private int m_Year;
        private PanelControl panelControl1;
        private TimeEdit teFromDate;
        private TimeEdit teToDate;

        public event UnShiftDataHandler UnShiftData;

        public xfmInsertSymbol()
        {
            this.components = null;
            this.m_Month = 0;
            this.m_Year = 0;
            this.InitializeComponent();
            this.InitData();
        }

        public xfmInsertSymbol(int Month, int Year)
        {
            this.components = null;
            this.m_Month = 0;
            this.m_Year = 0;
            this.InitializeComponent();
            this.m_Month = Month;
            this.m_Year = Year;
            this.InitData();
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btCreate_Click(object sender, EventArgs e)
        {
            if (this.glkSymbol.EditValue == null)
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn k\x00fd hiệu chấm c\x00f4ng!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if ((int.Parse(this.calFromRow.Text) < 1) || (int.Parse(this.calToRow.Text) < 1))
            {
                XtraMessageBox.Show("Số d\x00f2ng kh\x00f4ng được nhỏ hơn 1!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (int.Parse(this.calFromRow.Text) > int.Parse(this.calToRow.Text))
            {
                XtraMessageBox.Show("Số d\x00f2ng đến kh\x00f4ng được nhỏ hơn số d\x00f2ng đi!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (int.Parse(this.teFromDate.Text) > int.Parse(this.teToDate.Text))
            {
                XtraMessageBox.Show("Ng\x00e0y bắt đầu kh\x00f4ng được nhỏ hơn ng\x00e0y kết th\x00fac!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else
            {
                this.RaiseUnShiftDataHandler(this.glkSymbol.EditValue.ToString(), int.Parse(this.teFromDate.Text), int.Parse(this.teToDate.Text), int.Parse(this.calFromRow.Text), int.Parse(this.calToRow.Text), this.cheAll.Checked);
                base.Close();
            }
        }

        private void cheAll_CheckedChanged(object sender, EventArgs e)
        {
            if (this.cheAll.Checked)
            {
                this.calFromRow.Enabled = false;
                this.calToRow.Enabled = false;
            }
            else
            {
                this.calFromRow.Enabled = true;
                this.calToRow.Enabled = true;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitData()
        {
            this.teFromDate.EditValue = new DateTime(this.m_Year, this.m_Month, 1);
            this.teToDate.EditValue = new DateTime(this.m_Year, this.m_Month, 1);
            this.calFromRow.EditValue = 1;
            this.calToRow.EditValue = 1;
            new DIC_SYMBOL().AddGridLookupEdit(this.glkSymbol);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmInsertSymbol));
            this.btCreate = new SimpleButton();
            this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components);
            this.btCancel = new SimpleButton();
            this.lcDescription = new LabelControl();
            this.panelControl1 = new PanelControl();
            this.labelControl1 = new LabelControl();
            this.glkSymbol = new GridLookUpEdit();
            this.gridLookUpEdit1View = new GridView();
            this.colSymbolCode = new GridColumn();
            this.colSymbolName = new GridColumn();
            this.teFromDate = new TimeEdit();
            this.teToDate = new TimeEdit();
            this.calFromRow = new CalcEdit();
            this.calToRow = new CalcEdit();
            this.labelControl2 = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.labelControl4 = new LabelControl();
            this.labelControl5 = new LabelControl();
            this.groupBox1 = new GroupBox();
            this.groupBox2 = new GroupBox();
            this.cheAll = new CheckEdit();
            this.imageCollection1.BeginInit();
            this.panelControl1.BeginInit();
            this.panelControl1.SuspendLayout();
            this.glkSymbol.Properties.BeginInit();
            this.gridLookUpEdit1View.BeginInit();
            this.teFromDate.Properties.BeginInit();
            this.teToDate.Properties.BeginInit();
            this.calFromRow.Properties.BeginInit();
            this.calToRow.Properties.BeginInit();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.cheAll.Properties.BeginInit();
            base.SuspendLayout();
            this.btCreate.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCreate.ImageIndex = 2;
            this.btCreate.ImageList = this.imageCollection1;
            this.btCreate.Location = new Point(0xb0, 10);
            this.btCreate.Name = "btCreate";
            this.btCreate.Size = new Size(0x6a, 0x17);
            this.btCreate.TabIndex = 2;
            this.btCreate.Text = "Đồng \x00dd (>>)";
            this.btCreate.Click += new EventHandler(this.btCreate_Click);
            this.imageCollection1.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection1.ImageStream");
            this.imageCollection1.Images.SetKeyName(0, "ico_alpha_Search_16x16.png");
            this.imageCollection1.Images.SetKeyName(1, "ico_alpha_Delete_16x16.png");
            this.imageCollection1.Images.SetKeyName(2, "document2.png");
            this.imageCollection1.Images.SetKeyName(3, "open-16x16.png");
            this.imageCollection1.Images.SetKeyName(4, "close.png");
            this.btCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCancel.ImageIndex = 4;
            this.btCancel.ImageList = this.imageCollection1;
            this.btCancel.Location = new Point(0x12a, 10);
            this.btCancel.Name = "btCancel";
            this.btCancel.Size = new Size(0x62, 0x17);
            this.btCancel.TabIndex = 3;
            this.btCancel.Text = "Tho\x00e1t";
            this.btCancel.Click += new EventHandler(this.btCancel_Click);
            this.lcDescription.Appearance.Options.UseTextOptions = true;
            this.lcDescription.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.lcDescription.AutoSizeMode = LabelAutoSizeMode.None;
            this.lcDescription.Location = new Point(0x11, 5);
            this.lcDescription.Name = "lcDescription";
            this.lcDescription.Size = new Size(0x17b, 0x38);
            this.lcDescription.TabIndex = 4;
            this.lcDescription.Text = "    Chọn k\x00fd hiệu chấm c\x00f4ng từ \x00f4 ph\x00eda b\x00ean dưới, sau đ\x00f3 chọn ph\x00e1t sinh từ ng\x00e0y n\x00e0o đến ng\x00e0y n\x00e0o v\x00e0 từ d\x00f2ng n\x00e0o đến d\x00f2ng n\x00e0o trong lưới danh s\x00e1ch.";
            this.panelControl1.Appearance.BackColor = Color.Transparent;
            this.panelControl1.Appearance.Options.UseBackColor = true;
            this.panelControl1.BorderStyle = BorderStyles.NoBorder;
            this.panelControl1.Controls.Add(this.btCancel);
            this.panelControl1.Controls.Add(this.btCreate);
            this.panelControl1.Dock = DockStyle.Bottom;
            this.panelControl1.Location = new Point(0, 0xc5);
            this.panelControl1.Name = "panelControl1";
            this.panelControl1.Size = new Size(0x19b, 0x2b);
            this.panelControl1.TabIndex = 6;
            this.labelControl1.Location = new Point(0x23, 0x43);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(120, 13);
            this.labelControl1.TabIndex = 9;
            this.labelControl1.Text = "Chọn k\x00fd hiệu chấm c\x00f4ng:";
            this.glkSymbol.Location = new Point(0xa1, 0x41);
            this.glkSymbol.Name = "glkSymbol";
            this.glkSymbol.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkSymbol.Properties.NullText = "<Chọn k\x00fd hiệu chấm c\x00f4ng>";
            this.glkSymbol.Properties.View = this.gridLookUpEdit1View;
            this.glkSymbol.Size = new Size(0xa5, 20);
            this.glkSymbol.TabIndex = 10;
            this.gridLookUpEdit1View.Columns.AddRange(new GridColumn[] { this.colSymbolCode, this.colSymbolName });
            this.gridLookUpEdit1View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridLookUpEdit1View.Name = "gridLookUpEdit1View";
            this.gridLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit1View.OptionsView.ShowAutoFilterRow = true;
            this.gridLookUpEdit1View.OptionsView.ShowGroupPanel = false;
            this.colSymbolCode.Caption = "M\x00e3";
            this.colSymbolCode.FieldName = "SymbolCode";
            this.colSymbolCode.Name = "colSymbolCode";
            this.colSymbolCode.Visible = true;
            this.colSymbolCode.VisibleIndex = 0;
            this.colSymbolName.Caption = "T\x00ean k\x00fd hiệu";
            this.colSymbolName.FieldName = "SymbolName";
            this.colSymbolName.Name = "colSymbolName";
            this.colSymbolName.Visible = true;
            this.colSymbolName.VisibleIndex = 1;
            this.teFromDate.EditValue = new DateTime(0x7dc, 7, 3, 0, 0, 0, 0);
            this.teFromDate.Location = new Point(0x4c, 30);
            this.teFromDate.Name = "teFromDate";
            this.teFromDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teFromDate.Properties.Mask.EditMask = "dd";
            this.teFromDate.Size = new Size(0x39, 20);
            this.teFromDate.TabIndex = 11;
            this.teToDate.EditValue = new DateTime(0x7dc, 7, 3, 0, 0, 0, 0);
            this.teToDate.Location = new Point(0x4c, 0x3d);
            this.teToDate.Name = "teToDate";
            this.teToDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teToDate.Properties.Mask.EditMask = "dd";
            this.teToDate.Size = new Size(0x39, 20);
            this.teToDate.TabIndex = 12;
            int[] bits = new int[4];
            this.calFromRow.EditValue = new decimal(bits);
            this.calFromRow.Enabled = false;
            this.calFromRow.Location = new Point(0x3e, 0x39);
            this.calFromRow.Name = "calFromRow";
            this.calFromRow.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calFromRow.Size = new Size(0x2b, 20);
            this.calFromRow.TabIndex = 13;
            bits = new int[4];
            this.calToRow.EditValue = new decimal(bits);
            this.calToRow.Enabled = false;
            this.calToRow.Location = new Point(0xa8, 0x39);
            this.calToRow.Name = "calToRow";
            this.calToRow.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calToRow.Size = new Size(0x2b, 20);
            this.calToRow.TabIndex = 14;
            this.labelControl2.Location = new Point(0x12, 0x21);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x2c, 13);
            this.labelControl2.TabIndex = 15;
            this.labelControl2.Text = "Từ ng\x00e0y:";
            this.labelControl3.Location = new Point(0x12, 0x40);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x33, 13);
            this.labelControl3.TabIndex = 0x10;
            this.labelControl3.Text = "Đến ng\x00e0y:";
            this.labelControl4.Location = new Point(0x70, 60);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x33, 13);
            this.labelControl4.TabIndex = 0x12;
            this.labelControl4.Text = "Đến d\x00f2ng:";
            this.labelControl5.Location = new Point(12, 0x3b);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x2c, 13);
            this.labelControl5.TabIndex = 0x11;
            this.labelControl5.Text = "Từ d\x00f2ng:";
            this.groupBox1.Controls.Add(this.teToDate);
            this.groupBox1.Controls.Add(this.labelControl3);
            this.groupBox1.Controls.Add(this.teFromDate);
            this.groupBox1.Controls.Add(this.labelControl2);
            this.groupBox1.Location = new Point(0x11, 0x5f);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(150, 0x61);
            this.groupBox1.TabIndex = 0x13;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Chọn ng\x00e0y";
            this.groupBox2.Controls.Add(this.cheAll);
            this.groupBox2.Controls.Add(this.calToRow);
            this.groupBox2.Controls.Add(this.calFromRow);
            this.groupBox2.Controls.Add(this.labelControl4);
            this.groupBox2.Controls.Add(this.labelControl5);
            this.groupBox2.Location = new Point(0xb0, 0x5f);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(220, 0x61);
            this.groupBox2.TabIndex = 20;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Chọn d\x00f2ng";
            this.cheAll.EditValue = true;
            this.cheAll.Location = new Point(10, 0x1b);
            this.cheAll.Name = "cheAll";
            this.cheAll.Properties.Caption = "Tất cả c\x00e1c d\x00f2ng";
            this.cheAll.Size = new Size(0xbf, 0x13);
            this.cheAll.TabIndex = 0x13;
            this.cheAll.CheckedChanged += new EventHandler(this.cheAll_CheckedChanged);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x19b, 240);
            base.Controls.Add(this.groupBox2);
            base.Controls.Add(this.groupBox1);
            base.Controls.Add(this.glkSymbol);
            base.Controls.Add(this.labelControl1);
            base.Controls.Add(this.panelControl1);
            base.Controls.Add(this.lcDescription);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmInsertSymbol";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "Ch\x00e8n nhanh k\x00fd hiệu chấm c\x00f4ng";
            this.imageCollection1.EndInit();
            this.panelControl1.EndInit();
            this.panelControl1.ResumeLayout(false);
            this.glkSymbol.Properties.EndInit();
            this.gridLookUpEdit1View.EndInit();
            this.teFromDate.Properties.EndInit();
            this.teToDate.Properties.EndInit();
            this.calFromRow.Properties.EndInit();
            this.calToRow.Properties.EndInit();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.cheAll.Properties.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void RaiseUnShiftDataHandler(string Symbol, int FromDate, int ToDate, int FromRow, int ToRow, bool IsCheckAll)
        {
            if (this.UnShiftData != null)
            {
                this.UnShiftData(this, Symbol, FromDate, ToDate, FromRow, ToRow, IsCheckAll);
            }
        }

        public delegate void UnShiftDataHandler(object sender, string Symbol, int FromDate, int ToDate, int FromRow, int ToRow, bool IsCheckAll);
    }
}

